package ufcg.edu.br.projetoles.util;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class InfoChecker {
	final static int MAX_TAM_EMAIL = 50;
	
	public static boolean emailCheck(String email)  {
		boolean resp = false;
		Pattern pt = Pattern
				.compile("([\\p{L}]([_\\.]?[\\w &&[^_\\.\\s]])*){1}@[\\p{L}]+(\\.[\\p{L}]+)+\\s*");
		if (email != null) {
			Matcher mt = pt.matcher(email);
			if (mt.matches() && email.length() <= MAX_TAM_EMAIL) {
				resp = true;
			}
		}

		return resp;
	}
	
	public static boolean dataCheck(String data,String hora){
		Calendar calendar = Calendar.getInstance();
		Calendar c1 = new GregorianCalendar();
		String[] dt = data.split("/");
		String[] hr = hora.split(":");	
		c1.set(Integer.parseInt(dt[2]), Integer.parseInt(dt[1])-1, Integer.parseInt(dt[0]), Integer.parseInt(hr[0]), Integer.parseInt(hr[1]));
		
		
		
		return c1.before(calendar);
		
		
	}
	

}
